import axios, { AxiosRequestConfig } from 'axios'

import { IRouteLine } from './interface'
import { flatteRouteData } from './utils'
import './__mock__'

/** 获取路由链路 */
export const apiGetOriginalRouteInfo = async (
  waybillNo: string,
  signal?: AxiosRequestConfig['signal'],
): Promise<IRouteLine[]> => {
  return axios
    .post(`/tmsapi/track_waybill/waybillLine`, { waybillNo }, { $extra: 'noAuth', signal })
    .then(res => flatteRouteData(res.$data || []))
}
